<?php
class keyword extends Zend_Db_Table{
	protected $_name='plm_keyword';

	public function __construct(){
			parent::__construct();			
			$this->db=Zend_Registry::get('dbAdapter');
	}

	function edit($info)
	{
		Zend_Loader::loadClass('Zend_Filter_StripTags');
		$filter = new Zend_Filter_StripTags();
		$keyword_client_id=trim($filter->filter($info['keyword_client_id']));
		$keyword_name = trim($filter->filter($info['keyword_name']));
		$keyword_link = trim($filter->filter($info['keyword_link']));		
		if ($keyword_name && $keyword_link) {
			$data = array(
				'keyword_client_id'	=> $keyword_client_id,
				'keyword_name'	 	=> $keyword_name,
				'keyword_link'	 	=> $keyword_link
				);
			if (!empty($info['keyword_id'])) {
				$id = intval($filter->filter($info['keyword_id']));
				$this->update($data,'keyword_id='.$id);	
			} else {
				$this->insert($data);
			}
			
			return true;
		}

	}
	
	function count_add($ids){
		$_info=array(
					'keyword_count'	=> new Zend_Db_Expr('keyword_count+1')
					);
		foreach($ids as $id){
			$this->update($_info,"keyword_id=".$id);
			}
		return true;
		}
	
	function del($ids){		
		if(is_numeric($ids)){
			$this->delete("keyword_id=".$ids);
			return true;
			}
		else{
			$this->delete("keyword_id in ($ids)");
			return true;
			}
		}

		
}
?>